#include<bits/stdc++.h>
using namespace std;
const int mx=2e5+5;
int T,n;
int A[mx],C[mx];
int cnt;
bool vis[mx];

int main()
{
    freopen("color.in", "r", stdin);
    freopen("color.out","w",stdout);
    cin>>T;
    while(T--){
        cnt=0;
        cin>>n;
        for(int i=1;i<=n;i++){
            vis[i]=1;
        }
        int k[mx];
        for(int i=1;i<=n;i++){
            cin>>k[i];
        }
        for(int i=1;i<=n;i++){
            for(int j=i+1;j<=n;j++){
                if(k[j]==k[i] && vis[i] && vis[j]){
                    cnt+=k[i];
                    vis[i]=0;
                    vis[j]=0;
                    break;
                }
            }
        }
        cout<<cnt<<endl;
    }
    fclose(stdin);
    fclose(stdout);
    return 0;
}
